﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Distribution.Dto
@using FwProject.Core.Distribution
@model IPagedList<DistributionDetailsView>

@{
    Layout = null;
    int SumDistributioncount = 0;
    int SumDistributionBycount = 0;
    int SumRecoverycount = 0;
    int SumRecoveryBycount = 0;
    int SumExchangegoodscount = 0;
    int SumExchangegoodsBycount = 0;
    int SumDamagecount = 0;
    int SumGivecount = 0;
    int SumGiveBycount = 0;
    int SumBackboxcount = 0;
    int SumBacknumbercount = 0;
    int SumBackBoxByCount = 0;
    decimal SumPrice = 0;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {
            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th class="collapsed"></th>
                <th style="width:45px">序号</th>
                <th>状态</th>
                <th>配送单号</th>
                <th>配送日期</th>
                <th>餐厅名称</th>
                <th>配送司机</th>
                <th>车牌号</th>
                <th>店存</th>
                <th>配送箱数</th>
                <th>配送套数</th>
                <th>回收箱数</th>
                <th>回收套数</th>
                <th>换货箱数</th>
                <th>换货套数</th>
                <th>折损套数</th>
                <th>赠送箱数</th>
                <th>赠送套数</th>
                <th>退回箱数</th>
                <th>退回套数</th>
                <th>退套总数</th>
                <th>应收金额（￥）</th>

                @*<th style="width:200px;">操作</th>*@
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="22">暂无配送单信息</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    i++;
                    <tr data-value="@item.Id">
                        <td class="collapsed"><i class="fa fa-plus-square-o" data-id="@item.Id"></i></td>
                        <td>@i</td>
                        @if (item.Pricestatus == Pricestatus.已配送 || item.Pricestatus == Pricestatus.未结账)
                        {
                            <td style="color:red">@item.Pricestatus</td>
                        }
                        else
                        {
                            <td style="color:green">@item.Pricestatus</td>
                        }

                        <td><a href="javascript:top.window.openTab(1111,'配送单[@item.CreationNumber]','@Url.Action("DetailsInformation",new { id=item.Id})')">@item.CreationNumber</a></td>
                        <td>@item.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                        <td>@item.RestaurantName</td>
                        <td>@item.Name</td>
                        <td>@item.PlatesNumber</td>
                        <td>@item.Stock</td>
                        <td>@item.Distributioncount</td>
                        <td>@item.DistributionBycount</td>
                        <td>@item.Recoverycount</td>
                        <td>@item.RecoveryBycount</td>
                        <td>@item.Exchangegoodscount</td>
                        <td>@item.ExchangegoodsBycount</td>
                        <td>@item.Damagecount</td>
                        <td>@item.Givecount</td>
                        <td>@item.GiveBycount</td>
                        <td>@item.Backboxcount</td>
                        <td>@item.Backnumbercount</td>
                        <td>@item.BackboxSumBycount</td>
                        <td>@item.TotalPrice</td>
                    </tr>
                    <tr data-selectable="false" class="tb-child hidden">
                        <td colspan="20">
                            <div class="row m-b-lg">
                                <div class="col-sm-12" style="width:100%">
                                    <div class="tabs-container">
                                        <div class="tabs-left">
                                            <div class="tab-content ">
                                                <div class="tab-pane active">
                                                    <div class="panel-body" style="width:100%; margin-left:0;">
                                                        <table class="table table-bordered table-hover table-rowselected table-rowselected">
                                                            <thead class="disnot">
                                                                <tr>
                                                                    <th>货品型号</th>
                                                                    <th>配送箱数</th>
                                                                    <th>配送套数</th>
                                                                    <th>回收箱数</th>
                                                                    <th>回收套数</th>
                                                                    <th>换货箱数</th>
                                                                    <th>换货套数</th>
                                                                    <th>折损套数</th>
                                                                    <th>赠送箱数</th>
                                                                    <th>赠送套数</th>
                                                                    <th>退回箱数</th>
                                                                    <th>退回套数</th>
                                                                    <th>状态</th>
                                                                    <th>单价（￥）</th>
                                                                    <th>应支付金额（￥）</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody class="tb_tbody"></tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    SumDistributioncount += item.Distributioncount;
                    SumDistributionBycount += item.DistributionBycount;
                    SumRecoverycount += item.Recoverycount;
                    SumRecoveryBycount += item.RecoveryBycount;
                    SumExchangegoodscount += item.Exchangegoodscount;
                    SumExchangegoodsBycount += item.ExchangegoodsBycount;
                    SumDamagecount += item.Damagecount;
                    SumGivecount += item.Givecount;
                    SumGiveBycount += item.GiveBycount;
                    SumBackboxcount += item.Backboxcount;
                    SumBacknumbercount += item.Backnumbercount;
                    SumBackBoxByCount += item.BackboxSumBycount;
                    SumPrice += item.TotalPrice;
                }
                @*<tr>
                        <td colspan="2" style="color:red;text-align:center">该页合计</td>
                        <td colspan="6"></td>
                        <td style="color:red">@SumDistributioncount</td>
                        <td style="color:red">@SumDistributionBycount</td>
                        <td style="color:red">@SumRecoverycount</td>
                        <td style="color:red">@SumRecoveryBycount</td>
                        <td style="color:red">@SumExchangegoodscount</td>
                        <td style="color:red">@SumExchangegoodsBycount</td>
                        <td style="color:red">@SumDamagecount</td>
                        <td style="color:red">@SumGivecount</td>
                        <td style="color:red">@SumGiveBycount</td>
                        <td style="color:red">@SumBackboxcount</td>
                        <td style="color:red">@SumBacknumbercount</td>
                        <td style="color:red">@SumPrice</td>
                    </tr>*@
                <tr class="footer" style="background-color:darkgray">
                    <td colspan="2" style="color:red;text-align:center">总合计</td>
                    <td colspan="7"></td>
                    <td style="color:red">@ViewBag.Distributioncount</td>
                    <td style="color:red">@ViewBag.DistributionBycount</td>
                    <td style="color:red">@ViewBag.Recoverycount</td>
                    <td style="color:red">@ViewBag.RecoveryBycount</td>
                    <td style="color:red">@ViewBag.Exchangegoodscount</td>
                    <td style="color:red">@ViewBag.ExchangegoodsBycount</td>
                    <td style="color:red">@ViewBag.Damagecount</td>
                    <td style="color:red">@ViewBag.Givecount</td>
                    <td style="color:red">@ViewBag.GiveBycount</td>
                    <td style="color:red">@ViewBag.Backboxcount</td>
                    <td style="color:red">@ViewBag.Backnumbercount</td>
                    <td style="color:red">@ViewBag.BackboxSumBycount</td>
                    <td style="color:red">@ViewBag.TotalPrice</td>
                </tr>
            }
        </tbody>
    </table>

</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页*@
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageNumber/@Model.PageCount 页

    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&RestaurantName=@(Context.Request.Query["RestaurantName"])&DriverName=@(Context.Request.Query["DriverName"])&beginTime=@(Context.Request.Query["beginTime"])&endTime=@(Context.Request.Query["endTime"])&key=1" />
        @Html.PagedListPager(Model, page => Url.Action("DistributionDetails", new { pageIdx = page, size = Context.Request.Query["size"], RestaurantName = Context.Request.Query["RestaurantName"], DriverName = Context.Request.Query["DriverName"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"], key = 1 }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>

